package com.taotao.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.taotao.web.service.IndexService;

/**
 * 首页
 * 
 * @author Beck
 *
 */

@Controller
public class IndexController {
    @Autowired
    private IndexService indexService;

    @RequestMapping("index")
    public ModelAndView toIndex() {
        ModelAndView mv = new ModelAndView("index");
        String indexAD1 = null;
        String indexAD2 = null;
        try {
            // 获取大广告
            indexAD1 = indexService.queryAd1();
            // 获取右上角小广告
            indexAD2 = indexService.queryAd2();
        } catch (Exception e) {
            e.printStackTrace();
        }
        // 向页面传入大广告
        mv.addObject("indexAD1", indexAD1);
        // 向页面传入小广告
        mv.addObject("indexAD2", indexAD2);

        return mv;
    }
}
